<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Http\Exports\UserImport;
use Maatwebsite\Excel\Facades\Excel;
use App\Http\Exports\InvoicesExport;
use App\Http\Exports\QueryExport;
use App\Http\Exports\QueryExportSailList;
use App\Http\Exports\QueryExportDeliveryList;
use App\Http\Exports\QueryExportNotpaiedList;
use App\Http\Exports\QueryExportGoodsSeilRank;

use App\Http\Exports\QueryArrayExport;

class ExcelController extends Controller
{

    public function export1()
    {
        return Excel::download(new CategoryController(), '/uploads/temp/15471063501364434453.csv');
    }



    public function import()
    {
         Excel::import(new UserImport(), '15471063501364434453.csv','local',\Maatwebsite\Excel\Excel::CSV);
    }

    //Excel文件导出功能 By Laravel学院
    public function export(){
        $cellData = [
            ['学号','姓名','成绩'],
            ['10001','AAAAA','99'],
            ['10002','BBBBB','92'],
            ['10003','CCCCC','95'],
            ['10004','DDDDD','89'],
            ['10005','EEEEE','96'],
        ];

        return Excel::download(new QueryArrayExport(), 'invoices.csv',\Maatwebsite\Excel\Excel::CSV);
//        return Excel::download(new QueryExport(), 'query.csv',\Maatwebsite\Excel\Excel::CSV);
//        return Excel::download(new QueryExport(), 'query.pdf',\Maatwebsite\Excel\Excel::TCPDF);
//        return Excel::download(new QueryExport(), 'query.pdf',\Maatwebsite\Excel\Excel::MPDF);
//        return Excel::download(new QueryExport(), 'query.pdf',\Maatwebsite\Excel\Excel::DOMPDF);
    }

    public function exp_sail_list(Request $request){

        $param = $request->all();

        return Excel::download(new QueryExportSailList($param), 'exp_sail_list.csv',\Maatwebsite\Excel\Excel::CSV);
    }

    public function exp_delivery_list(Request $request){

        $param = $request->all();

        return Excel::download(new QueryExportDeliveryList($param), 'exp_delivery_list.csv',\Maatwebsite\Excel\Excel::CSV);
    }

    public function exp_notpaied_list(Request $request){

        $param = $request->all();

        return Excel::download(new QueryExportNotpaiedList($param), 'exp_notpaied_list.csv',\Maatwebsite\Excel\Excel::CSV);
    }

    public function exp_goods_seil_rank(Request $request){

        $param = $request->all();

        return Excel::download(new QueryExportGoodsSeilRank($param), 'exp_goods_seil_rank.csv',\Maatwebsite\Excel\Excel::CSV);
    }
}
